<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

use App\Http\Models\Message;


class MessageController extends AdminBaseController {

    public function __construct(Request $request){
        parent::__construct($request);
        $this->param['active'] = 'message';
    }


    public function index(){

        $message = Message::orderBy('created_at',"desc")->paginate(20);
        $this->param['data'] = $message;

        return view("admin.message.index",$this->param);
    }

    public function edit($id){

        $message = Message::find($id);
        $this->param['content'] = $message;

        return view("admin.message.edit",$this->param);
    }

    public function changeStatus($id){

        $message = Message::find($id);
        $message-> status = ($message->status)?0:1;
        $message->save();
        return response()->json(['state'=>'ok','message'=>'操作成功']);

    }

}


